/*
 * @Description: 我的收藏
 * @Author: iamsmiling
 * @Date: 2021-06-13 09:01:31
 * @LastEditTime: 2021-06-16 07:09:51
 */
import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/base/future_loadstate_builder.dart';
import 'package:credit_business_circle/components/topic_card/topic_card.dart';
import 'package:credit_business_circle/domain/local/topic/topic_entity.dart';
import 'package:credit_business_circle/domain/remote/topic/topic_log_entity.dart';
import 'package:credit_business_circle/pages/mine/children/my_collection/my_collection_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class MyCollectionPage extends GetView<MyCollectionController> {
  const MyCollectionPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("我的收藏"),
        elevation: .5,
      ),
      body: FutureLoadStateBuilder<MyCollectionController>(
          controller: controller,
          builder: (_) {
            return ListView.builder(
                padding: EdgeInsets.symmetric(horizontal: R.dimen.dp10),
                itemCount: _.list.length,
                itemBuilder: (BuildContext context, int i) {
                  TopicLogEntity log = _.list[i];
                  return Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Container(
                          margin: EdgeInsets.only(
                              top: R.dimen.dp20, bottom: R.dimen.dp13),
                          child: Text(
                            log.date,
                            style: TextStyle(
                                fontSize: R.dimen.sp12,
                                color: R.color.ff666666),
                          )),

                      for (TopicEntity topic in log.topics)
                        Stack(
                          children: [
                            TopicCard(
                              topic: topic,
                              borderColor: R.color.transparent,
                              margin: EdgeInsets.only(bottom: R.dimen.dp10),
                              bannerVisible: false,
                              bottomRightBuilder: (BuildContext context) {
                                return GestureDetector(
                                  onTap: () => _.cancel(log, topic),
                                  child: Row(
                                    children: [
                                      Image.asset(R.image.collectionStar),
                                      Container(
                                        margin:
                                            EdgeInsets.only(left: R.dimen.dp6),
                                        child: Text(
                                          "取消收藏",
                                          style: TextStyle(
                                              fontSize: R.dimen.sp11,
                                              color: R.color.ffef4408),
                                        ),
                                      )
                                    ],
                                  ),
                                );
                              },
                            ),
                          ],
                        )
                      // Expanded(
                      //   child: AutoList(
                      //     items: log.topics,
                      //     duration: const Duration(milliseconds: 375),
                      //     itemBuilder: (BuildContext context, TopicEntity topic) {
                      //       return TopicCard(topic: topic);
                      //     },
                      //   ),
                      // )
                    ],
                  );
                });
          }),
    );
  }
}
